package main

import (
	"context"
	blobpb "coolcar/blob/api/gen/v1"
	"fmt"

	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
)

func main() {
	// 创建gRPC client
	conn, err := grpc.Dial(
		"localhost:8083",
		grpc.WithTransportCredentials(insecure.NewCredentials()), // 在内网里面都是insecure(不安全)的连接，这也是可以接受的
	)
	if err != nil {
		panic(err)
	}
	c := blobpb.NewBlobServiceClient(conn)

	// 直接调用方法进行测试
	ctx := context.Background()
	// res, err := c.CreateBlob(ctx, &blobpb.CreateBlobRequest{
	// 	AccountId:           "account_1",
	// 	UploadUrlTimeoutSec: 1000,
	// })

	// res, err := c.GetBlob(ctx, &blobpb.GetBlobRequest{
	// 	Id: "630dadcb535053df1bb53502", // 创建blob时候的ID
	// })

	res, err := c.GetBlobURL(ctx, &blobpb.GetBlobURLRequest{
		Id:         "630dadcb535053df1bb53502", // 创建blob时候的ID
		TimeoutSec: 100,
	})
	if err != nil {
		panic(err)
	}
	fmt.Printf("%+v\n", res)
}
